package com.shujia.controller;

import com.shujia.bean.Student;
import com.shujia.service.StudentService;
import com.shujia.service.StudentServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StudentController {

    StudentService studentService = new StudentServiceImpl();

    /**
     * 通过学号查询学生信息的接口（api,数据服务，数据接口）
     * <p>
     * http://localhost:8080/query?id=1500100001&key=123456
     */
    @GetMapping("/query")
    public Student query(String id, String key) {

        Student student = studentService.queryStudentById(id, key);

        //spring 会自动将实体类转换成一个json字符串
        return student;
    }


    //http://localhost:8080/queryByCache?id=1500100001&key=123456
    @GetMapping("/queryByCache")
    public Student queryByCache(String id, String key) {

        Student student = studentService.queryStudentByIdAndCache(id, key);

        //spring 会自动将实体类转换成一个json字符串
        return student;
    }


}
